package com.zerui.manager.web;

import com.zerui.authority.annotation.Authorize;
import com.zerui.cola.dto.PageResponse;
import com.zerui.cola.dto.Response;
import com.zerui.manager.web.cmd.AccessAuthDeviceBindCmd;
import com.zerui.manager.web.cmd.AccessAuthDeviceQryCmd;
import com.zerui.manager.web.vo.AccessAuthDevicePageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * @Author wh
 * @create_time 2023-08-23 15:33
 */
@Validated
@Api(value = "门禁授权设备绑定", tags = "门禁设备管理")
@RestController
@RequestMapping("/api/v1/access/auth/device")
public class AccessAuthDeviceController {

    @Resource
    private AccessAuthDeviceService accessAuthDeviceService;

	@ApiOperation(value = "门禁授权设备分页列表", tags = "门禁授权管理")
	@PostMapping("/getPageList")
	public PageResponse<AccessAuthDevicePageVO> getPageList(@RequestBody @Validated AccessAuthDeviceQryCmd accessAuthDeviceQryCmd) {
		return accessAuthDeviceService.getPageList(accessAuthDeviceQryCmd);
	}

	@ApiOperation(value = "门禁授权 - 设备绑定", tags = "门禁授权管理")
	@PostMapping("/bind")
	public Response add(@RequestBody @Validated AccessAuthDeviceBindCmd accessAuthDeviceBindCmd) {
		return accessAuthDeviceService.add(accessAuthDeviceBindCmd);
	}

	@ApiOperation(value = "门禁授权 - 取消绑定", tags = "门禁授权管理")
	@PostMapping("/cancel/bind")
	public Response delete(@RequestBody @Validated AccessAuthDeviceBindCmd accessAuthDeviceBindCmd) {
		return accessAuthDeviceService.delete(accessAuthDeviceBindCmd);
	}

	@ApiOperation(value = "设备同步", tags = "门禁授权管理")
	@PostMapping("/sync")
	public Response sync() {
		return accessAuthDeviceService.sync();
	}

}
